/*
 *  CSE 40166, Computer Graphics, Fall 2013
 *  Assignment 4, Part 2
 *
 *  File: Object.h
 *
 *  Kevin Sonnen
 *
 *  Description: Contains declaration of classes used to store an object
 *
 */

#ifndef OBJECT_H
#define OBJECT_H

// Include libraries
#include <iostream>
#include <stdlib.h>	// exit
#include <string>
#include <algorithm>
#include <fstream>	// ifstream
#include <vector>
#include <math.h>

// Include OpenGL, GLUT
#ifdef __APPLE__			// If compiling on Mac OS
	#include <GLUT/glut.h>
#else					// Else compiling on Linux OS
	#include <GL/glut.h>
	#include <GL/gl.h>
	#include <GL/glu.h>
#endif

// A struct for a single 3D point
typedef struct point {
	GLfloat coord[3];
} point;

// A struct for a single 2D point
typedef struct point_2d {
	GLfloat coord[2];
} point_2d;

// A struct for the bounding box of an object
typedef struct bounds {
	GLfloat minX;
	GLfloat maxX;
	GLfloat minY;
	GLfloat maxY;
	GLfloat minZ;
	GLfloat maxZ;
} bounds;

// A class for a single face
// A face must have 3 vertex indices
// It also can have an optional: Texture Coordinate, and Normal Coordinate
class face {
	public:
		face();
		void setVertexIndices(const unsigned int &v1, const unsigned int &v2, const unsigned int &v3);
		void setTextureIndices(const unsigned int &t1, const unsigned int &t2, const unsigned int &t3);
		void setNormalIndices(const unsigned int &n1, const unsigned int &n2, const unsigned int &n3);
		unsigned int *getVertexIndices();
		unsigned int *getTextureIndices();
		unsigned int *getNormalIndices();
		bool mapTexture();
		bool mapNormals();
	private:
		unsigned int *vertexIndices;
		bool hasTexture;
		unsigned int *textureIndices;
		bool hasNormals;
		unsigned int *normalIndices;
};

// A class for storing an Object
class Object {
	public:
		void addVertices(const point & mVerts);
		float faceArea(const unsigned int &index);
		void setDiameter();
		GLfloat * getVertexLocation(const int &faceNum, const int &vertNum);
		GLfloat * getVertexNormals(const int &faceNum, const int &vertNum);
		GLfloat * getVertexTextureCoords(const int &faceNum, const int &vertNum);
		std::vector<point> vertices, normals;
		std::vector<point_2d> textures;
		std::vector<face> faces;
		unsigned int numFaces;
		bounds boundingBox;
		float diameter;
		
};

#endif // OBJECT_H
